module.exports=class extends baseController{
    constructor(){
        super();
        this.config = require('../upload-handler/config');
        this.router.all('/control',this.control.bind(this));
        return this.router;
    }

    static init(){
        return new this();
    }


    async control(req,res){
        let action = req.body.action || req.query.action || "";
        try {
            switch (action) {
                case "config":
                    res.json(this.config);
                    break;
                case "uploadimage":
                    await require('../upload-handler/upload-image-handler')(req, res).handler();
                    break;
                case "uploadscrawl":
                    await require('../upload-handler/upload-scrawl-handler')(req, res).handler();
                    break;
                case "uploadvideo":
                    await require('../upload-handler/upload-video-handler')(req, res).handler();
                    break;
                    case "uploadfile":
                    await require('../upload-handler/upload-file-handler')(req, res).handler();
                    break;
                    case "listimage":
                     require('../upload-handler/list-image-handler')(req, res).handler();
                     break;
                     case "listfile":
                     require('../upload-handler/list-file-handler')(req, res).handler();
                     break;
            }
        } catch (err) {
            res.json(err);
        }
    }

}
